#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>

#define MaxSize 100
typedef struct Stack
{
	int data[MaxSize];
	int top;
}Stack;

//初始化栈
void InitStack(Stack* stack)
{
	stack->top = -1;
    // stack->top == (*stack).top

}
//判断空栈
bool isEmpty(Stack* stack)
{
	if (stack->top == -1)
		return true;
	else 
		return false;
}
//进栈
void Push(Stack* stack, int data)
{
	if(stack->top>=MaxSize-1)
		printf("Stack has been full!!!\n");
	else
	{
		stack->top++;	
		stack->data[stack->top] = data;
	}

}
//出栈
void Pop(Stack* stack,int *data)
{
	if(isEmpty(stack))
		printf("Stack has been empty!!!\n");
	else
		*data = stack->data[stack->top--];	

	// 等同于 
	// *data = stack->data[stack->top];
	// stack->top--;
}
//读栈顶元素
int GetTop(Stack* stack){
	if(isEmpty(stack))
	{
		printf("Stack has been empty!!!\n");
		return -1;
	}
	else	
		return stack->data[stack->top];	

}

//遍历栈
void Print(Stack stack)
{
	for(int i=stack.top;i>=0;i--)
		printf("stack.data[%d] is %d\n",i,stack.data[stack.top--])
}
//销毁栈
void Destroy(Stack* stack);
{
	stack->top = -1;
}

int main(){
    Stack stack;
    int i=0;
    InitStack(&stack);

}
